home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / hc2_x / tcprogud.sit / TC Prog Guide / card_16112.txt < prev    next >
Text File  |  1991-02-27  |  1KB  |  20 lines

  1. -- card: 16112 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 4755
  5. -- name: 
  6.  
  7.  
  8. -- part contents for background part 4
  9. ----- text -----
  10.     delete(person);
  11.  
  12. As mentioned earlier, automatic variables are allocated and deallocated automatically when the function in which they are declared is entered and exited.  This applies to the pointer variable person, as well.  The space used by this variable to store the address of a Person object is automatically deallocated when the main function ends.
  13.  
  14. However, the space occupied by the object itself (space for two integers plus the            "housekeeping" values used by TC) is NOT deallocated and therefore is not reclaimed in case the program needs it later.  (Of course this is of little significance in this case since the entire program terminates when main terminates.  Later we will define objects from within functions other than main, and deallocation will be relevant.)
  15.  
  16. Since the 'new()' function was used to dynamically allocate a Person object, it is the programmer's responsibility to deallocate this space.  This is accomplished with the delete() function, whose argument should be a pointer to an object.  Like new(),  delete() is declared in the file oops.h.  (Again, in C++ delete is implemented as an operator, so oops.h is not needed.)
  17.  
  18. -- part contents for background part 7
  19. ----- text -----
  20. 37